package uk.co.agileworks.bidpirate.model.json;

import java.text.DecimalFormat;
import java.text.NumberFormat;

import org.apache.commons.lang.builder.ToStringBuilder;

import uk.co.agileworks.bidpirate.model.CurrencyAndPrice;

public final class ItemPrice {

	private static final NumberFormat FORMATTER = new DecimalFormat("#,##0.00");

	private CurrencyAndPrice beforeUpdate, afterUpdate;

	public ItemPrice(CurrencyAndPrice beforeUpdate, CurrencyAndPrice afterUpdate) {
		this.beforeUpdate = beforeUpdate;
		this.afterUpdate = afterUpdate;
	}

	public String getCurrency() {
		return afterUpdate.getCurrency();
	}

	public String getNewPrice() {
		return FORMATTER.format(afterUpdate.getPrice());
	}

	public String getOldPrice() {
		return FORMATTER.format(beforeUpdate.getPrice());
	}

	public boolean isUpdated() {
		return !beforeUpdate.equals(afterUpdate);
	}

	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this);
	}
	
}
